package com.tiiime.k.imagemap;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import map.MapPoint;
import map.ImageMap;
import map.MapWidget;
import map.TouchImage;


public class MyActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        ImageMap map = (ImageMap)findViewById(R.id.touch);
        Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.a);
        map.setBitmap(bm);

        View _post = getLayoutInflater().inflate(R.layout.post, null);
        View _llll = getLayoutInflater().inflate(R.layout.lll,  null);

        MapWidget wpost = new MapWidget(_post);
        MapWidget wllll = new MapWidget(_llll);
        wpost.setRenderDelegate(new MapWidget.RenderDelegate() {
            @Override
            public void onDisplay(MapPoint point, View widget) {

            }
        });
        wllll.setRenderDelegate(new MapWidget.RenderDelegate() {
            @Override
            public void onDisplay(MapPoint point, View widget) {

            }
        });

        MapPoint point_0 = new MapPoint("01", Color.RED);
        MapPoint point_1 = new MapPoint("05", Color.YELLOW);

        float x_0 = 500;  //随机x坐标，实际中，可以从服务器获取
        float y_0 = 500; //随机y坐标
        float x_1 = 450;  //随机x坐标，实际中，可以从服务器获取
        float y_1 = 450; //随机y坐标

        point_0.setPosition(x_0, y_0);
        point_1.setPosition(x_1, y_1);

        map.addPointWithWidget(point_0, wllll);
        map.addPointWithWidget(point_1, wpost);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
